package com.ayn.aynsystem.utils;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 运单状态枚举
 *
 * @author NXKJ_007
 */

@Getter
@AllArgsConstructor
public enum WaybillStatusEnum {

    /**
     * 运单状态枚举
     */
    FINISH("finish", "运输完成"),
    UNLOADING("unloading", "待装货"),
    GOING("going", "运输中");

    public static void main(String[] args) {
        System.out.println(UNLOADING.getValue());
    }
    private final String code;
    private final String value;

    public static String getCode(String value) {
        for (WaybillStatusEnum waybillStatusEnum : values()) {
            if (waybillStatusEnum.value.equals(value)) {
                return waybillStatusEnum.code;
            }
        }
        return UNLOADING.code;
    }

    /**
     * 返回枚举值，用于枚举类型校验
     *
     * @param value 值
     * @return 返回null时校验失败
     */
    public static String getValue(String value) {

        for (WaybillStatusEnum waybillStatusEnum : values()) {
            if (waybillStatusEnum.value.equals(value)) {
                return value;
            }
        }

        return null;
    }

}
